package com.qnw.CardGroupManagement;

import android.os.*;
import android.support.v4.app.*;
import android.view.*;
import android.widget.*;
import com.ygo.feihua.*;
import org.json.*;
import java.io.*;

public class FragmentZhaohuanci extends Fragment
{
	private TextView xg;

	private String km;
	
	private Gongju gj;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
	{
		View v=inflater.inflate(R.layout.fragment_xiaoguo,null);

		xg=(TextView) v.findViewById(R.id.xg);
		A5 a5=(A5) getActivity();
		km=a5.getCard().getId();
	
		gj=Gongju.getdx(getActivity());
		//assets中文件名字
		String fileName = "HisWords.txt";
		try
		{
			//拿到输入流
			InputStream in = getActivity().getAssets().open(fileName);
			//this.getResources().openRawResource(R.raw.json);
			byte[] buffer = new byte[in.available()];
			in.read(buffer);
			//将字节数组转换为以UTF-8编码的字符串
			String json = new String(buffer, "UTF-8");
			//将字符串json转换为json对象，以便于取出数据
			try
			{
				JSONObject jsonObject = new JSONObject(json);
				JSONArray zhc=jsonObject.getJSONArray(km);
				String jo=zhc.getString(0);
				xg.setText(jo);
				
			}catch (JSONException e){
				xg.setText("未查询到该卡召唤词");
				
				
			}
			
			
			in.close();
			
		}
		catch (IOException e)
		{

		}
		//String jso= gj.gethttps(Gongju.URL_YGO233_CARD_DIALOGUES);
		/*
		try
		{
			JSONArray zhc=jso.getJSONArray(km);
			String jo=zhc.getString(0);
			xg.setText(jo);
		}
		catch (JSONException e)
		{
			xg.setText("未查询到该卡召唤词");
			
		}
if(jso!=null){
	xg.setText(jso);
}else{
	xg.setText("没有");
}
*/

		
		// TODO: Implement this method
		return v;
	}


}
